<!-- Bootstrap -->
<script src="__CONSOLE__/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="__CONSOLE__/vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="__CONSOLE__/vendors/nprogress/nprogress.js"></script>
<!-- iCheck -->
<script src="__CONSOLE__/vendors/iCheck/icheck.min.js"></script>

<!-- Datatables -->
<!--<script src="__CONSOLE__/vendors/datatables.net/js/jquery.dataTables.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-buttons/js/buttons.print.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>-->
<!--<script src="__CONSOLE__/vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/jszip/dist/jszip.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/pdfmake/build/pdfmake.min.js"></script>-->
<!--<script src="__CONSOLE__/vendors/pdfmake/build/vfs_fonts.js"></script>-->
<!--第一步：引入Javascript / CSS （CDN）-->
<!-- DataTables CSS -->
<!-- DataTables -->
<!--<script type="text/javascript" charset="utf8" src="http://cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>-->
<!-- Switchery左右滑动开关 -->
<script src="__CONSOLE__/vendors/switchery/dist/switchery.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="__CONSOLE__/build/js/custom.min.js"></script>
<script src="__CONSOLE__/public.js"></script>
<script src="__PLUGIN__/layer/layer.js"></script>
<script src="__PLUGIN__/select2/dist/js/select2.js"></script>
<script src="__PLUGIN__/select2/dist/js/select2.full.js"></script>
<!-- daterangepicker -->
<link href="__CONSOLE__/css/custom.css" rel="stylesheet">
<script type="text/javascript" src="__CONSOLE__/moment/moment.min.js"></script>
<script type="text/javascript" src="__CONSOLE__/datepicker/daterangepicker.js"></script>
<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__PLUGIN__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PLUGIN__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PLUGIN__/editor/lang/zh-cn/zh-cn.js"></script>
<script>
    // 实例化编辑器
    var ue = UE.getEditor('containers');
    var ue = UE.getEditor('containers_content');
    var ue = UE.getEditor('containers_content2');
    var ue = UE.getEditor('containers_editor');
</script>

<script type="text/javascript">
    //new uploadPreview({ UpBtn: "user_logo",Width: 20,Height: 20, ImgShow: "user_logo_im" ,callback: function() { }});
    //new uploadPreview({ UpBtn: "up_img1",Width: 20,Height: 20, DivShow: "imgdiv1",ImgShow: "imgShow1" ,callback: function() { }});

    $("#add").click(function(){
        $("#add").append($(".turquoise2").clone(true));
    });

    function rem(t){
        var mythis = $(t);
        var i = mythis.parent().index();
        var length =  mythis.parent().parent().find('.file-tab').length;
        if(length <= 1){
            layer.msg('唯一图片不能删除');
            return false;
        }
        mythis.parent().remove();

    }
</script>
<script type="text/javascript">

    $(document).ready(function(){
        $("#add").click(function(){
            upload();
        });
    });

    function single(single_pic){
        var timeStamp = new Date().getTime();
        var containerTemplate = '<div class="file-tab panel-body" id="imgdiv'+timeStamp+'" style="display: inline-block;">' +
            '<img id="imgShow'+timeStamp+'" src="__CONSOLE__/default.png" alt="Image preview" class="thumbnail" />' +
            '<label class="btn btn-default">选择文件' +
            '<input type="file" name="'+single_pic+'" id="up_img'+timeStamp+ '"style="display: none;" required/>' +
            '</label>' +
            '<label class="btn btn-default" onclick="rem(this)">移除文件</label>'
        '</div>';
        $("#"+single_pic).last().append(containerTemplate);
        var targetSetting = {
            UpBtn: "up_img"+timeStamp,
            DivShow: "imgdiv"+timeStamp,
            ImgShow: "imgShow"+timeStamp,
            callback:this.callback
        };

        //配置文件使用递归的方式来处理
        new uploadPreview(targetSetting);
    }

</script>

<!--有这个验证器失效-->
<!--<link rel="stylesheet" href="__CONSOLE__/amazeui/amazeui.min.css" />-->
<!--<script src="__CONSOLE__/amazeui/jquery.min.js"></script>-->
<!--<script src="__CONSOLE__/amazeui/amazeui.js"></script>-->

<link href="__PLUGIN__/Fileinput/css/fileinput.css" rel="stylesheet">
<!-- 图片上传 -->
<script src="__PLUGIN__/Fileinput/js/fileinput.js"></script>
<script>

fileinputOne("single_pic");
fileinputOne("single_pic2");
fileinputOne("headimgurl",true);
fileinputOne("id_card_font");
fileinputOne("id_card_back");
fileinputOne("wap_single_pic");
fileinputOne("single_pic1");
fileinputOne("logo_pic");
fileinputMore('multi_pic','temp_multi_pic[]','multi_pic[]');
fileinputMore('multi_pic2','temp_multi_pic2[]','multi_pic2[]');
fileinputOne("upload_one");
fileinputMore('upload_many','temp_upload_many[]','upload_many[]');
    //单图上传

    function fileinputOne(fileid,is_original = false){
        var widths = arguments[2] ? arguments[2] : 'auto';//设置默认的图片宽度
        var heights = arguments[3] ? arguments[3] : '160px';//设置默认的图片高度
        //单图上传
        var $input = $('[name="'+fileid+'"]').prev();//file_input
        var $picurl = $('[name="'+fileid+'"]'); // img_url
        // console.log($picurl);
        // console.log($picurl.val());
        var $Preview =[];
        var $Config =[];
        if($picurl.val()!=''){
            $Preview =["<img class='kv-preview-data file-preview-image' style='width:"+widths+";height:"+heights+";' src='"+$picurl.val()+"'>"];
            $Config =[{key: 1}];
        }
        if(is_original){
            var uploadUrl = "{:url('console/common/upload')}?rule=true";
        }else{
            var uploadUrl = "{:url('console/common/upload')}";
        }
        $input.fileinput({
            uploadUrl: uploadUrl,
            deleteUrl: "{:url('console/common/updel')}",
            autoReplace: true,
            overwriteInitial: true,
            showUploadedThumbs: false,
            maxFileCount: 1,
            initialPreview: $Preview,
            initialPreviewConfig: $Config,
            layoutTemplates: {actionDelete: ''},
        }).on("filebatchselected", function(event, files) {
            $input.fileinput("upload");//选择后自动上传
        }).on('fileuploaded', function(event, data,previewId,index) {

            console.log(data);
            var dataObj=eval("("+data.response+")");
            if(dataObj['code']==0)
            {
                console.log();
                $picurl.val(dataObj['img']);
            }
            else{
                swal("出错了", "上传失败,请刷新再试", "error");
            }
        }).on("filecleared", function(event, files) {
            $picurl.val('');
        });

    }
    //组图上传
    function fileinputMore(fileid,picurlname,field){
        var widths = arguments[3] ? arguments[3] : 'auto';//设置默认的图片宽度
        var heights = arguments[4] ? arguments[4] : '160px';//设置默认的图片高度
        //组图上传
        var $input = $("#"+fileid);
        var $picimg = $("input[name='"+picurlname+"']");

        var $Preview =[];
        var $Config =[];
        $picimg.each(function(i,e){
            $Preview.push("<img class='kv-preview-data file-preview-image'  style='width:"+widths+";height:"+heights+";' src='"+$(this).val()+"'>");
            $Config.push({caption: $(this).attr('flag'),show: $(this).attr('show'),size:0,url:"<input type='hidden' name='"+field+"' value='"+$(this).val()+"'>", key: i});

        });

        var footerTemplate = '<div class="file-thumbnail-footer">\n' +
            '   <div style="margin:5px 0">\n' +
            '       <input type="text" class="hidden" value="{show}" name="show[]"><input class="kv-input kv-new form-control input-sm text-center" value="{caption}" placeholder="填写注释" name="info[]">\n' +
            '   </div>\n' +
            '   <button type="button" class="kv-file-forward text-info header-left" title="前移"><i class="glyphicon glyphicon-chevron-left"></i></button>\n' +
            '   &nbsp;{size}&nbsp;\n' +
            '   <button type="button" class="kv-file-backward text-danger header-right" title="后移"><i class="glyphicon glyphicon-chevron-right"></i></button>\n' +
            // '   <button type="button" class="kv-file-heart text-danger header-left" title="显示隐藏"><i class="glyphicon glyphicon-heart{show}"></i></button>\n' +
            '   {actions}\n' +
            '</div>';

        $input.fileinput({
            uploadUrl: "{:url('console/common/upload')}",
            deleteUrl: "{:url('console/common/updel')}",
            autoReplace: false,
            overwriteInitial: false,
            layoutTemplates: {footer: footerTemplate, size: '<samp><small>({sizeText})</small></samp>'},
            initialPreview: $Preview,
            initialPreviewConfig: $Config,
        }).on("filebatchselected", function(event, files) {
            $input.fileinput("upload");//选择后自动上传
        }).on('fileuploaded', function(event, data,previewId,index) {
            var dataObj=eval("("+data.response+")");
            if(dataObj['code']==0)
            {
                $('#'+previewId).append("<input type='hidden' name='"+field+"' value='"+dataObj['img']+"'>");
            }
            else{
                swal("出错了", "上传失败,请刷新再试", "error");
            }
        });
    }
</script>
<link rel="stylesheet" type="text/css" href="__PLUGIN__/oss-h5/style.css"/>
<script type="text/javascript" src="__PLUGIN__/oss-h5/lib/crypto1/crypto/crypto.js"></script>
<script type="text/javascript" src="__PLUGIN__/oss-h5/lib/crypto1/hmac/hmac.js"></script>
<script type="text/javascript" src="__PLUGIN__/oss-h5/lib/crypto1/sha1/sha1.js"></script>
<script type="text/javascript" src="__PLUGIN__/oss-h5/lib/base64.js"></script>
<script type="text/javascript" src="__PLUGIN__/oss-h5/lib/plupload-2.1.2/js/plupload.full.min.js"></script>
<script type="text/javascript" src="__PLUGIN__/oss-h5/upload.js"></script>









